//
// OpenTemplate
// Copyright (c) 2006
// by OpenArrow Software ( http://www.openarrow.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using System.Text;
using OpenArrow.Templating.Properties;

namespace OpenArrow.Templating.Parsing
{
    /// <summary>
    /// Represents a segment from a template file
    /// </summary>
    public class Segment
    {
        #region Private Fields

        private bool isLiteral;
        private string contents;
        private int startLine;
        private int endLine; 

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets a boolean indicating if the segment is a code or literal segment
        /// </summary>
        public bool IsLiteral
        {
            get { return isLiteral; }
            set { isLiteral = value; }
        }

        /// <summary>
        /// Gets or sets the contents of the segment
        /// </summary>
        public string Contents
        {
            get { return contents; }
            set { contents = value; }
        }

        /// <summary>
        /// Gets or sets the line number on which the segment starts
        /// </summary>
        public int StartLine
        {
            get { return startLine; }
            set { startLine = value; }
        }

        /// <summary>
        /// Gets or sets the line number on which the segment ends
        /// </summary>
        public int EndLine
        {
            get { return endLine; }
            set { endLine = value; }
        } 

        #endregion

        #region Public Constructors

        /// <summary>
        /// Constructs a new <see cref="Segment"></see> object
        /// </summary>
        /// <param name="isLiteral">A boolean indicating if the segment is a code or literal segment</param>
        /// <param name="contents">The contents of the segment</param>
        /// <param name="startLine">The line number on which the segment starts</param>
        /// <param name="endLine">The line number on which the segment ends</param>
        /// <exception cref="ArgumentException"><paramref name="contents"/> is <see langword="null"/> or <see cref="String.Empty"/></exception>
        public Segment(bool isLiteral, string contents, int startLine, int endLine)
        {
            if (String.IsNullOrEmpty(contents))
                throw new ArgumentException(String.Format(Resources.Exception_ArgIsNullOrEmpty, "contents"), "contents");

            this.Contents = contents;
            this.IsLiteral = isLiteral;
            this.StartLine = startLine;
            this.EndLine = endLine;
        } 

        #endregion
    }
}
